using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using MEA.AE_Data;

namespace MEA.AE_BusinessLogic
{
	public class UIGraphWindow : Form
	{
		public delegate void EventhandlerBool(bool condition);

		private UIGraphBase uiGraph1;

		private IContainer components;

		public UIGraphBase UiGraph1
		{
			get
			{
				return uiGraph1;
			}
		}

		public event EventHandler AbortThread;

		public event UIGraphBase.SaveHandler Save;

		public UIGraphWindow(UIGraphBase uigraph)
		{
			uiGraph1 = uigraph;
			uiGraph1.AbortThread += uiGraph1_AbortThread;
			uiGraph1.SaveButtonPressed += uiGraph1_SaveButtonPressed;
			base.SizeChanged += uiGraph1.ResizeUiGraph1;
			InitializeComponent();
			CenterToScreen();
			if (uiGraph1.graphicAspect == ConfigBase.EGraphicAspect.eShowGraphDataLog)
			{
				Text = "Data-Logger";
			}
			else
			{
				Text = "Live View";
			}
		}

		private void uiGraph1_SaveButtonPressed(object logpath, ArrayList functs)
		{
			if (this.Save != null)
			{
				this.Save(logpath, functs);
			}
		}

		private void uiGraph1_AbortThread(object sender, EventArgs e)
		{
			if (this.AbortThread != null)
			{
				this.AbortThread(sender, e);
			}
		}

		private void UIGraphWindow_FormClosing(object sender, FormClosingEventArgs e)
		{
			if (this.AbortThread != null)
			{
				this.AbortThread(sender, e);
			}
		}

		protected override void Dispose(bool disposing)
		{
			if (disposing && components != null)
			{
				components.Dispose();
			}
			base.Dispose(disposing);
		}

		private void InitializeComponent()
		{
			base.SuspendLayout();
			this.uiGraph1.BgColor = System.Drawing.Color.FromArgb(252, 254, 254);
			this.uiGraph1.Graphmode = MEA.AE_BusinessLogic.UIGraphBase.Mode.stay;
			this.uiGraph1.Location = new System.Drawing.Point(5, 5);
			this.uiGraph1.Name = "uiGraph1";
			this.uiGraph1.TabIndex = 0;
			base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
			base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
			base.Controls.Add(this.uiGraph1);
			base.MaximizeBox = true;
			base.Name = "UIGraphWindow";
			base.FormClosing += new System.Windows.Forms.FormClosingEventHandler(UIGraphWindow_FormClosing);
			base.ResumeLayout(false);
			this.uiGraph1.Focus();
		}
	}
}
